<!doctype html>
<html>
<head>
<meta charset="utf-8">

<title>绘制线条-闭合</title>
<style>
body {background:black; text-align:center;}
#c1 {background:white;}
</style>
<script>
window.onload=function ()
{
	var oC=document.getElementById('c1');
	var gd=oC.getContext('2d');
	
	gd.beginPath();
	gd.moveTo(100,100);
	gd.lineTo(50,300);
	gd.lineTo(400,310);
	gd.lineTo(410,80);
	
	//选择1.自己画
//	gd.lineTo(100, 100);
	
	//选择2.closePath——不只是连到起点(还会闭合)
	gd.closePath();
	
	gd.lineWidth=5;
	gd.stroke();
};
</script>
</head>

<body>
<canvas id="c1" width="800" height="600"></canvas>
</body>
</html>





